<!-- 父组件App.vue -->
<template>
    <PersonD1 ref="ren"/>
    <button @click="test">测试</button>
</template>
  
  <script lang="ts" setup name="AppD1">
    import PersonD1 from './componentsdemo2/PersonD1.vue';
    import {ref} from 'vue'
  
    let ren = ref()// 实例化子组件,并将实例对象存储在ren变量中。
  
    function test(){
      console.log(ren.value.name)
      console.log(ren.value.age)
    }
  </script>